using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using eyeLog.Core;

namespace eyeLog
{
    public partial class RegisterDialog : Form
    {
        public RegisterDialog()
        {
            InitializeComponent();
        }

        private void btOK_Click(object sender, EventArgs e)
        {
            myErrors.Clear();
            if (txtLicenseKey.Text.Length == 0)
                myErrors.SetError(txtLicenseKey, "Please give a value");
            else
            {
                Properties.Settings.Default.LicenseKey = txtLicenseKey.Text;
                Properties.Settings.Default.Save();
                if (MessageBox.Show("Thank you for registering\nYour copy will be activated the next time you start it.\n\nWould you like to restart now?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Process.Start(Environment.CommandLine.Replace("\"", ""));
                    Application.Exit();
                }
                else
                    DialogResult = DialogResult.OK;
            }
        }

        private void RegisterDialog_Load(object sender, EventArgs e)
        {
#if DEBUG
            LicenseBase lic;
            lic = new LicenseBase(4, 1, 1, 1, new DateTime(2099,12,31), new DateTime(2099,12,31), 0);
            txtLicenseKey.Text = lic.ToString();
#endif
        }
    }
}